<include file="Common:layout" />
<script type="text/javascript" src="__PUBLIC__/usr/js/layer/laydate/laydate.js"></script>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>授权添加</h3>
            </div>
        </div>
    </div>
    <div id="explanation" class="explanation">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">添加授权提醒</h4>
            <span title="收起提示" id="explanationZoom"></span>
        </div>
        <ul>
            <li>表单数据请务必填写正确！</li>
            <li>下载的文件请先加密再发送使用方！</li>
        </ul>
    </div>
    <form class="form-horizontal" id="handleposition" action="{:U('Author/new_author')}" method="post">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>公司名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="company" id="company" class="w300">
                    <span class="err"></span>
                    <p class="notic">请填写公司名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>到期时间</label>
                </dt>
                <dd class="opt">
                    <input type="checkbox" name="forever" value="1" id="use_forever"/>永久
                    <input type="text" name="use_end" id="use_end" class="w100" onclick="laydate({istime:true, format: 'YYYY-MM-DD'})"/>
                    <p class="notic">填写格式：2017-10-01</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>客户IP</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="ip" id="ip" class="w100">
                    <span class="err"></span>
                    <p class="notic">例：127.0.0.1</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>客户域名</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="url" id="url" class="w300">
                    <span class="err"></span>
                    <p class="notic">填写方式，例：http://www.BaiDu.com/ 则填：www.baidu.com（全小写）</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label>加密字符</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="auth_salt" id="auth_salt" class="w100">
                    <span class="err"></span>
                    <p class="notic">请填写英文数字组合，最大长度13</p>
                </dd>
            </dl>
            <div class="bot"><a class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $("#use_forever").click(function(){
            if($(this).attr("checked")){
                $("#use_end").attr("disabled",true);
            }else{
                $("#use_end").attr("disabled",false);
            }
        });
        $("#submitBtn").click(function(){
            var company = $("#company").val();
            var use_end = $("#use_end").val();
            var auth_salt = $("#auth_salt").val();
            var ip = $("#ip").val();
            var url = $("#url").val();
            if(!company){
                layer.alert("公司名称必填");return false;
            }
            if(!$("#use_forever").attr("checked") && !use_end){
                layer.alert("请填到期时间");return false;
            }
            if(!ip){
                layer.alert("IP必填");return false;
            }
            if(!url){
                layer.alert("URL必填");return false;
            }
            var salt_rule = /^[A-Za-z0-9]{0,13}$/;
            if(!salt_rule.test(auth_salt)){
                layer.alert("加密字符填写有误");return false;
            }
            $('#handleposition').submit();
        });
    });
</script>
</body>
</html>